<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: MessagesController</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">MessagesController</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/app/controllers/messages_controller_rb.html">
                app/controllers/messages_controller.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="ApplicationController.html">
                ApplicationController
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000019">archive</a>&nbsp;&nbsp;
      <a href="#M000021">create</a>&nbsp;&nbsp;
      <a href="#M000024">destroy</a>&nbsp;&nbsp;
      <a href="#M000022">edit</a>&nbsp;&nbsp;
      <a href="#M000016">list</a>&nbsp;&nbsp;
      <a href="#M000013">mark_as_read</a>&nbsp;&nbsp;
      <a href="#M000020">new</a>&nbsp;&nbsp;
      <a href="#M000025">new_ajax</a>&nbsp;&nbsp;
      <a href="#M000015">new_message_patient</a>&nbsp;&nbsp;
      <a href="#M000018">out</a>&nbsp;&nbsp;
      <a href="#M000017">show</a>&nbsp;&nbsp;
      <a href="#M000014">toggle</a>&nbsp;&nbsp;
      <a href="#M000023">update</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000019" class="method-detail">
        <a name="M000019"></a>

        <div class="method-heading">
          <a href="#M000019" class="method-signature">
          <span class="method-name">archive</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000019-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 57</span>
57:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">archive</span>
58:       <span class="ruby-ivar">@message_pages</span>, <span class="ruby-ivar">@messages</span>= <span class="ruby-identifier">paginate</span> <span class="ruby-identifier">:messages</span>, <span class="ruby-identifier">:per_page=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">20</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;recipient_id=?&quot;</span>,<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">id</span>]
59:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000021" class="method-detail">
        <a name="M000021"></a>

        <div class="method-heading">
          <a href="#M000021" class="method-signature">
          <span class="method-name">create</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000021-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 82</span>
 82:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>
 83:     <span class="ruby-ivar">@message</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:message</span>])
 84:     <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">sender_id</span>=<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">id</span>
 85:     <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">status</span>=<span class="ruby-value">0</span>
 86:     <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">thread</span><span class="ruby-operator">==</span><span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">or</span> <span class="ruby-operator">!</span> <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">thread</span>
 87:       <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">thread</span>=<span class="ruby-ivar">@message</span>.<span class="ruby-identifier">id</span>
 88:     <span class="ruby-keyword kw">end</span>
 89:     <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">save</span>
 90:       <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">'Message was successfully created.'</span>
 91:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:return</span>]<span class="ruby-operator">==</span><span class="ruby-value str">&quot;patient&quot;</span>
 92:         <span class="ruby-identifier">recipient</span>=<span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-ivar">@message</span>.<span class="ruby-identifier">recipient_id</span>)
 93:         <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:controller=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">&quot;admin&quot;</span>,<span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'show'</span>,<span class="ruby-identifier">:identifier=</span><span class="ruby-operator">&gt;</span><span class="ruby-identifier">recipient</span>.<span class="ruby-identifier">username</span>
 94:       <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:return</span>]<span class="ruby-operator">==</span><span class="ruby-value str">&quot;patient_user&quot;</span>
 95:         <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:controller=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">&quot;admin&quot;</span>,<span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'show'</span>,<span class="ruby-identifier">:identifier=</span><span class="ruby-operator">&gt;</span><span class="ruby-ivar">@message</span>.<span class="ruby-identifier">re</span>
 96:       <span class="ruby-keyword kw">else</span>
 97:          <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'index'</span>
 98:       <span class="ruby-keyword kw">end</span>
 99:     <span class="ruby-keyword kw">else</span>
100:       <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'new'</span>
101:     <span class="ruby-keyword kw">end</span>
102:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000024" class="method-detail">
        <a name="M000024"></a>

        <div class="method-heading">
          <a href="#M000024" class="method-signature">
          <span class="method-name">destroy</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000024-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 120</span>
120:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">destroy</span>
121:     <span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>]).<span class="ruby-identifier">destroy</span>
122:     <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'list'</span>
123:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000022" class="method-detail">
        <a name="M000022"></a>

        <div class="method-heading">
          <a href="#M000022" class="method-signature">
          <span class="method-name">edit</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000022-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 104</span>
104:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">edit</span>
105:     <span class="ruby-ivar">@message</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
106:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000016" class="method-detail">
        <a name="M000016"></a>

        <div class="method-heading">
          <a href="#M000016" class="method-signature">
          <span class="method-name">list</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000016-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 40</span>
40:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list</span>
41:     <span class="ruby-ivar">@message_pages</span>, <span class="ruby-ivar">@messages</span> = <span class="ruby-identifier">paginate</span> <span class="ruby-identifier">:messages</span>, <span class="ruby-identifier">:per_page</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">10</span>
42:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="#M000013" class="method-signature">
          <span class="method-name">mark_as_read</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 9</span>
 9:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mark_as_read</span>
10:     
11:       <span class="ruby-ivar">@message</span>=<span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
12:       <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">update_attribute</span>(<span class="ruby-identifier">:status</span>,<span class="ruby-value">1</span>)
13:       <span class="ruby-comment cmt">#element_to_update=&quot;email_status_&quot;+@message.id.to_s</span>
14:       <span class="ruby-identifier">render</span> <span class="ruby-identifier">:update</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span>
15:           <span class="ruby-identifier">page</span>.<span class="ruby-identifier">replace_html</span>(<span class="ruby-value str">'message_count'</span>,<span class="ruby-value str">&quot;You have &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">pluralize</span>(<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">inbox</span>.<span class="ruby-identifier">size</span>, <span class="ruby-value str">&quot;unread message&quot;</span>))
16:           <span class="ruby-comment cmt">#page.replace_html(element_to_update,'Read')</span>
17:           <span class="ruby-comment cmt">#page.visual_effect :highlight, element_to_update</span>
18:           <span class="ruby-identifier">page</span>.<span class="ruby-identifier">visual_effect</span> <span class="ruby-identifier">:toggle_blind</span>, <span class="ruby-value str">&quot;message_&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@message</span>.<span class="ruby-identifier">id</span>.<span class="ruby-identifier">to_s</span>
19:           <span class="ruby-identifier">page</span>.<span class="ruby-identifier">replace_html</span>(<span class="ruby-value str">'sb_message_count'</span>,<span class="ruby-identifier">pluralize</span>(<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">inbox</span>.<span class="ruby-identifier">size</span>, <span class="ruby-value str">&quot;message&quot;</span>))
20:           <span class="ruby-identifier">page</span>.<span class="ruby-identifier">visual_effect</span> <span class="ruby-identifier">:highlight</span>,<span class="ruby-value str">'sb_message_count'</span>
21:           
22:           <span class="ruby-comment cmt">#page.hide(&quot;message-&quot;+@message.id.to_s)</span>
23:       <span class="ruby-keyword kw">end</span>
24: 
25:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000020" class="method-detail">
        <a name="M000020"></a>

        <div class="method-heading">
          <a href="#M000020" class="method-signature">
          <span class="method-name">new</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000020-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 61</span>
61:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new</span>
62:     <span class="ruby-ivar">@message</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">new</span>
63:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:recipient_id</span>])
64:       <span class="ruby-ivar">@recipient_user</span>=<span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:recipient_id</span>])
65:     <span class="ruby-keyword kw">end</span>
66:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:re_id</span>])
67:       <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">re</span>=<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:re_id</span>]
68:       <span class="ruby-ivar">@re</span>=<span class="ruby-constant">Patient</span>.<span class="ruby-identifier">find_current</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:re_id</span>])
69:     <span class="ruby-keyword kw">end</span>
70:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:thread</span>])
71:       <span class="ruby-ivar">@oldMessage</span>=<span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:thread</span>])
72:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">subject</span>.<span class="ruby-identifier">starts_with?</span>([<span class="ruby-value str">&quot;re:&quot;</span>,<span class="ruby-value str">&quot;Re:&quot;</span>,<span class="ruby-value str">&quot;re &quot;</span>,<span class="ruby-value str">&quot;Re &quot;</span>])
73:         <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">subject</span>=<span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">subject</span>
74:       <span class="ruby-keyword kw">else</span>
75:         <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">subject</span>=<span class="ruby-value str">&quot;re: &quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">subject</span>
76:       <span class="ruby-keyword kw">end</span>
77:       <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">thread</span>=<span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">thread</span>
78:     <span class="ruby-keyword kw">end</span>
79:     <span class="ruby-identifier">session</span>[<span class="ruby-identifier">:return</span>]=<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:return</span>]
80:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000025" class="method-detail">
        <a name="M000025"></a>

        <div class="method-heading">
          <a href="#M000025" class="method-signature">
          <span class="method-name">new_ajax</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000025-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 125</span>
125:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new_ajax</span>
126:     <span class="ruby-ivar">@message</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">new</span>
127:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:recipient_id</span>])
128:       <span class="ruby-ivar">@recipient_user</span>=<span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:recipient_id</span>])
129:     <span class="ruby-keyword kw">end</span>
130:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:thread</span>])
131:       <span class="ruby-ivar">@oldMessage</span>=<span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:thread</span>])
132:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">subject</span>.<span class="ruby-identifier">starts_with?</span>(<span class="ruby-value str">&quot;re:&quot;</span>)
133:         <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">subject</span>=<span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">subject</span>
134:       <span class="ruby-keyword kw">else</span>
135:         <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">subject</span>=<span class="ruby-value str">&quot;re: &quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">subject</span>
136:       <span class="ruby-keyword kw">end</span>
137:       <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">thread</span>=<span class="ruby-ivar">@oldMessage</span>.<span class="ruby-identifier">thread</span>
138:     <span class="ruby-keyword kw">end</span>
139:     <span class="ruby-identifier">render</span> <span class="ruby-identifier">:partial=</span><span class="ruby-operator">&gt;</span><span class="ruby-value str">'new_ajax'</span>,  <span class="ruby-identifier">:layout=</span><span class="ruby-operator">&gt;</span><span class="ruby-keyword kw">false</span>
140:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000015" class="method-detail">
        <a name="M000015"></a>

        <div class="method-heading">
          <a href="#M000015" class="method-signature">
          <span class="method-name">new_message_patient</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000015-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 34</span>
34:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">new_message_patient</span>
35:     <span class="ruby-ivar">@message</span>=<span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
36:     <span class="ruby-identifier">render</span> <span class="ruby-identifier">:update</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span>
37:       <span class="ruby-identifier">page</span>.<span class="ruby-identifier">visual_effect</span> <span class="ruby-identifier">:toggle_blind</span>, <span class="ruby-value str">&quot;new_message_patient&quot;</span>    
38:     <span class="ruby-keyword kw">end</span>
39:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000018" class="method-detail">
        <a name="M000018"></a>

        <div class="method-heading">
          <a href="#M000018" class="method-signature">
          <span class="method-name">out</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000018-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 48</span>
48:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">out</span>
49:     <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:find</span>]<span class="ruby-operator">==</span><span class="ruby-value str">'unread'</span>)
50:       <span class="ruby-ivar">@message_pages</span>, <span class="ruby-ivar">@messages</span>= <span class="ruby-identifier">paginate</span> <span class="ruby-identifier">:messages</span>, <span class="ruby-identifier">:per_page=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">20</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;sender_id=? &amp;&amp; status=0&quot;</span>,<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">id</span>]
51:     <span class="ruby-keyword kw">else</span>
52:       <span class="ruby-ivar">@message_pages</span>,<span class="ruby-ivar">@messages</span>= <span class="ruby-identifier">paginate</span> <span class="ruby-identifier">:messages</span>, <span class="ruby-identifier">:per_page=</span><span class="ruby-operator">&gt;</span><span class="ruby-value">20</span>, <span class="ruby-identifier">:conditions=</span><span class="ruby-operator">&gt;</span>[<span class="ruby-value str">&quot;sender_id=?&quot;</span>,<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">id</span>]
53:     <span class="ruby-keyword kw">end</span>
54:    <span class="ruby-comment cmt">#@message_pages, @messages = paginate :messages, :per_page =&gt; 10, :conditions=&gt;{'sender_id'=&gt;@user.id}</span>
55:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000017" class="method-detail">
        <a name="M000017"></a>

        <div class="method-heading">
          <a href="#M000017" class="method-signature">
          <span class="method-name">show</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000017-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 44</span>
44:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">show</span>
45:     <span class="ruby-ivar">@message</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
46:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="#M000014" class="method-signature">
          <span class="method-name">toggle</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000014-source">
<pre>
    <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 27</span>
27:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">toggle</span>
28:     <span class="ruby-ivar">@message</span>=<span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
29:     <span class="ruby-identifier">render</span> <span class="ruby-identifier">:update</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span>
30:       <span class="ruby-identifier">page</span>.<span class="ruby-identifier">visual_effect</span> <span class="ruby-identifier">:toggle_blind</span>, <span class="ruby-value str">&quot;message_content_&quot;</span><span class="ruby-operator">+</span><span class="ruby-ivar">@message</span>.<span class="ruby-identifier">id</span>.<span class="ruby-identifier">to_s</span>    
31:     <span class="ruby-keyword kw">end</span>
32:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000023" class="method-detail">
        <a name="M000023"></a>

        <div class="method-heading">
          <a href="#M000023" class="method-signature">
          <span class="method-name">update</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000023-source">
<pre>
     <span class="ruby-comment cmt"># File app/controllers/messages_controller.rb, line 108</span>
108:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update</span>
109:     <span class="ruby-ivar">@message</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:id</span>])
110:     <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">status</span>=<span class="ruby-value">0</span>
111:     <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">sender_id</span>=<span class="ruby-ivar">@user</span>.<span class="ruby-identifier">id</span>
112:     <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@message</span>.<span class="ruby-identifier">update_attributes</span>(<span class="ruby-identifier">params</span>[<span class="ruby-identifier">:message</span>])
113:       <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">:notice</span>] = <span class="ruby-value str">'Message was successfully updated.'</span>
114:       <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'show'</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@message</span>
115:     <span class="ruby-keyword kw">else</span>
116:       <span class="ruby-identifier">render</span> <span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'edit'</span>
117:     <span class="ruby-keyword kw">end</span>
118:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>